package com.wanmait.employment.manageController;


import com.github.pagehelper.PageInfo;
import com.wanmait.employment.entity.CompanyType;
import com.wanmait.employment.entity.Industry;
import com.wanmait.employment.service.CompanyTypeService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("manage/CompanyType")
public class CompanyTypeController {
    @Resource
    private CompanyTypeService companyTypeService;
    @GetMapping("List")
    public AjaxResult List(String title, Integer pageNum, Integer pageSize){
        PageInfo<CompanyType> companyTypePageInfo=companyTypeService.selectList(title,pageNum,pageSize);
        return AjaxResult.success("",companyTypePageInfo);
    }
    @PostMapping("update")
    public AjaxResult update(@RequestBody CompanyType companyType){
        if(companyType.getId()!=null){
            companyTypeService.update(companyType);
            return AjaxResult.success("");
        }
        Boolean b=companyTypeService.insert(companyType);
        if(b){
            return AjaxResult.success("");
        }
        return AjaxResult.error("该行业已存在！");
    }
    @GetMapping("delete")
    public AjaxResult delete(Integer id){
       companyTypeService.delete(id);
        return AjaxResult.success("");
    }

}
